var fs = require('fs-promise');
var path = require('path');

var basePath = path.resolve(__dirname, '..') + '/';
var argv = Array.prototype.concat.apply([], process.argv);

var static = 'static';
var releaseType = argv[2] || 'dev';

resPath = basePath;

console.log('releaseType', releaseType);

var cpList = releaseType === 'dev' ? {
	'babel-polyfill': 'babel-polyfill/dist/polyfill.js',
	bluebird: 'bluebird/js/browser/bluebird.min.js',
	fetch: 'whatwg-fetch/fetch.js',
	react: 'react/dist/react.js',
	'react-dom': 'react-dom/dist/react-dom.js',
	'sw-toolbox': 'sw-toolbox/sw-toolbox.js',
	'url-search-params': 'url-search-params/build/url-search-params.js'
} : {
	'babel-polyfill': 'babel-polyfill/dist/polyfill.min.js',
	bluebird: 'bluebird/js/browser/bluebird.min.js',
	fetch: 'whatwg-fetch/fetch.js',
	react: 'react/dist/react.min.js',
	'react-dom': 'react-dom/dist/react-dom.min.js',
	'sw-toolbox': 'sw-toolbox/sw-toolbox.js',
	'url-search-params': 'url-search-params/build/url-search-params.js'
};

Object.keys(cpList).forEach(function(lib) {
	fs.copy(resPath + 'node_modules/' + cpList[lib], basePath + 'www/' + static + '/js/lib/' + lib + '.js');
});